package com.wsh.sms.service;

import com.wsh.sms.entity.Employee;
import com.wsh.sms.mapper.EmployeeMapper;
import com.wsh.sms.utils.AccountExist;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.List;

/**
 * @author wsh
 */
@Service
public class EmployeeService {
    private final EmployeeMapper employeeMapper;


    @Autowired
    private EmployeeService(EmployeeMapper employeeMapper){
        this.employeeMapper = employeeMapper;
    }

    public List<Employee> getAllEmployee(){
        return employeeMapper.getAllEmployee();
    }

    public Employee getOneEmployee(String number){
        return employeeMapper.getOneEmployee(number);
    }

    public int deleteOneEmployee(String number){return employeeMapper.deleteOneEmployee(number);}

    public int updateEmployee(String number,String name,String sex,int age,String yearIn,String old){
        return employeeMapper.updateEmployee(number,name,sex,age,yearIn,old);
    }

    public int addEmployee(String number,String name,String sex,int age,String yearIn){
        return employeeMapper.addEmployee(number,name,sex,age,yearIn);
    }

    public String  existNumber(String number){
        String result;
        if(employeeMapper.existNumber(number) == null){
            return AccountExist.NOT_EXIST.getExist();
        }
        else {
            result =  AccountExist.EXIST.getExist();
        }
        return result;
    }

}
